﻿var func_navi_submit = function () {
    $("#navi_form").submit();
}

$(function () {
    $(".navi1").hover(function (e) {
        $("#navi1").animate({ color: '#75AF1C' }, { speed: 2000, queue: false });
        $("#test_type").attr("value", "exam");
    }, function () {
        $("#navi1").animate({ color: '#000000' }, { speed: 0, queue: false });
        $("#test_type").attr("value", "");
    });
    //$("#navi1").bind("click", func_navi_submit);
    $(".navi2").hover(function (e) {
        clearTimeout(window.timer);
        $("#navi2").animate({ color: '#279FEB' }, { speed: 2000, queue: false });
        $("#test_type").attr("value", "practice");
        $(".all_terms").show(500).hover(
                    function () {
                        clearTimeout(window.timer);
                    }, function () {
                        $(".all_terms").hide();
                    });
    }, function () {
        $("#navi2").animate({ color: '#000000' }, { speed: 0, queue: false });
        $("#test_type").attr("value", "");
        window.timer = setTimeout(function () { $(".all_terms").hide(); }, 200);
    });
    //$("#navi2").bind("click", func_navi_submit)

    $(".navi3").hover(function (e) {
        clearTimeout(window.timer);
        $("#navi3").animate({ color: '#FE8D00' }, { speed: 2000, queue: false });
        $("#test_type").attr("value", "free");
        $(".all_terms").show(500).hover(
                    function () {
                        clearTimeout(window.timer);
                    }, function () {
                        $(".all_terms").hide();
                    });
    }, function () {
        $("#navi3").animate({ color: '#000000' }, { speed: 0, queue: false });
        $("#test_type").attr("value", "");
        window.timer = setTimeout(function () { $(".all_terms").hide(); }, 200);
    });
    $("#navi3").bind("click", func_navi_submit)

    $('.each_term').hover(function () {
        $("#which_term").attr("value", $(this).text());
        $(this).addClass('termShadow');
    }, function () {
        $("#which_term").attr("value", "");
        $(this).removeClass('termShadow');
    });
    $(".each_term").bind("click", func_navi_submit);

    var liColor;
    $("#courses_list li").hover(function () {
        liColor = $(this).css('background-color');
        $(this).animate({ backgroundColor: '#30A8F4' }, { speed: 1000, queue: false });
    }, function () {
        $(this).animate({ backgroundColor: liColor }, { speed: 1000, queue: false });
    });

    var oldFlag;
    var oldWidth;
    $("#courses_list li").click(function () {
        var newflag = $(this).attr('class');
        //alert(newflag);
        if (newflag == oldFlag)
            ;
        else {
            oldWidth = $(this).css('width');
            //alert(oldWidth);
            $(this).animate({ width: '250px' }, { speed: 1000, queue: false });
            $('.' + oldFlag).animate({ width: oldWidth }, { speed: 1000, queue: false });
            oldFlag = newflag;
        }
    });
});